package com.autumn.mybatis.provider.builder;

import com.autumn.mybatis.metadata.EntityTable;
import com.autumn.mybatis.provider.IDbProvider;
import com.autumn.mybatis.provider.IQueryBuilder;
import com.autumn.mybatis.provider.util.MybatisSqlUtils;

/**
 * 查询生成器
 * 
 * @author 杨昌国
 *
 *         2017-10-19 08:38:14
 */
public abstract class AbstractQueryBuilder extends AbstractBuilder implements IQueryBuilder {

	/**
	 * 
	 * @param dbProvider
	 */
	public AbstractQueryBuilder(IDbProvider dbProvider) {
		super(dbProvider);
	}

	/**
	 * 获取根据主键查询单条记录的sql
	 * 
	 * @param table
	 * @return
	 */
	@Override
	public String getSelectByPrimaryKeySql(EntityTable table) {
		return MybatisSqlUtils.selectByPrimaryKey(table);
	}

	/**
	 * 获取根据查询全部记录的sql
	 * 
	 * @param table
	 * @return
	 */
	@Override
	public String getSelectAllSql(EntityTable table) {
		return MybatisSqlUtils.selectAll(table);
	}

	/**
	 * 获取根据查询全部记录条数的sql
	 * 
	 * @param table
	 * @return
	 */
	@Override
	public String getCountByAllSql(EntityTable table) {
		return MybatisSqlUtils.selectAllCount(table);
	}
	
	@Override
	public String getHealthyCheckSql() {
		return "SELECT 1 AS Healthy";
	}
}
